import React, { Component } from 'react';
import { Suspense } from 'react';
import { useState } from 'react';
import { lazy } from 'react';
const DemoLazyChild=lazy(()=>import('./Demo'))
const DemoLazyIndex=()=>{
    const [show,setShow]=useState(false)
    const handleShow=()=>{
        setShow(!show)
    }
    return <div>
        异步组件（组件懒加载lazy）
        {
            show?<Suspense fallback={<div>加载中。。。</div>}><DemoLazyChild/></Suspense>:null
        }
        <button onClick={handleShow}>异步加载组件</button>
    </div>
}
export default DemoLazyIndex